# -*- coding = utf-8 -*-
# @Time : 2022/2/8 16:50
# @Author : 龙王赘婿_彪少
# @File : pptx_demo.py
# @Software: PyCharm
# https://blog.csdn.net/weixin_41261833/article/details/106406229

from pptx import Presentation
import os


class PPT:
    title = "嵌入式软件工程师技术路线图"
    data1_title = "强化基础编程能力"
    data1 = ["C/C++语言基础知识,和装逼能力",
             "内存管理，内存泄漏",
             "了解常见数据结构，以及数据结构存储方式，并将数据结构应用在对应场景",
             "熟悉运用相关算法(排序，搜索，路径规划，优化算法)，了解算法的时间空间复杂度",
             "养成良好的代码习惯以及编程风格"
             ]

    data2_title = "初级嵌入式知识"
    data2 = ["掌握ARM，TI芯片的裸机开发",
             "掌握并熟练开发单片机通信：IIC，SPI，UART，CAN，USB，ETH，SDIO"
             "掌握并熟练开发芯片外设：ADC，TIM，DMA，WatchDog，OTA",
             "熟练掌握，物联网卡，WIFI，磁编，IMU，4G，HTTP，微内核RTsmart，写消息队列等芯片的开发",
             ]

    data3_title = "高级嵌入式知识"
    data3 = ["熟练运用实时操作系统(RT_Thread)",
             "掌握Linux下的嵌入式开发，常见命令，多线程，消息量",
             "计算机网络，TCP/IP协议，MQTT协议，HTTP协议"
             "数据库：MYSQL，数据库设计"
             "掌握软件设计框架，了解设计模式"
             ]

    data4_title = "其他重要知识"
    data4 = ["运用Qt开发上位机",
             "运用Python处理相关数据",
             "利用matlab处理数据，仿真模型",
             "vue"
             ]

    def __init__(self):
        self.ppt = Presentation()

        self.func1()
        self.show_slide()
        self.ppt.save("../file/技术路线_LiuZhiBiao.pptx")
        os.system("E:/liuzhibiao/workspace_python/python-crawler/file/技术路线_LiuZhiBiao.pptx")

    def func(self):
        # 共0~10 11个添加模板，6为空白
        slide = self.ppt.slides.add_slide(self.ppt.slide_layouts[0])
        for shape in slide.placeholders:
            phf = shape.placeholder_format
            print(f"{phf.idx}--{shape.name}--{phf.type}")
            shape.text = f"{phf.idx}--{shape.name}--{phf.type}"

        print("-" * 40)
        slide = self.ppt.slides.add_slide(self.ppt.slide_layouts[1])
        for shape in slide.placeholders:
            phf = shape.placeholder_format
            print(f"{phf.idx}--{shape.name}--{phf.type}")
            shape.text = f"{phf.idx}--{shape.name}--{phf.type}"

    def func1(self):
        print("-" * 20 + "page1" + "-" * 20)
        slide = self.ppt.slides.add_slide(self.ppt.slide_layouts[0])
        slide.placeholders[0].text = "技术路线图"
        slide.placeholders[1].text = "为提高技术能力，提高核心竞争力，明确发展方向，满足公司人才需求，保障就业，特总结此嵌入式软件工程师技术路线图"

        print("-" * 20 + "page2" + "-" * 20)
        slide = self.ppt.slides.add_slide(self.ppt.slide_layouts[1])
        # 也可用slide.title
        slide.placeholders[0].text = self.title

        body_shape = slide.placeholders[1]
        tf = body_shape.text_frame
        tf.text = self.data1_title

        for data in self.data1:
            p = tf.add_paragraph()
            p.text = data
            p.level = 1

        print("-" * 20 + "page3" + "-" * 20)
        slide = self.ppt.slides.add_slide(self.ppt.slide_layouts[1])
        slide.placeholders[0].text = self.title

        body_shape = slide.placeholders[1]
        tf = body_shape.text_frame
        tf.text = self.data2_title

        for data in self.data2:
            p = tf.add_paragraph()
            p.text = data
            p.level = 1

        print("-" * 20 + "page4" + "-" * 20)
        slide = self.ppt.slides.add_slide(self.ppt.slide_layouts[1])
        slide.placeholders[0].text = self.title

        body_shape = slide.placeholders[1]
        tf = body_shape.text_frame
        tf.text = self.data3_title

        for data in self.data3:
            p = tf.add_paragraph()
            p.text = data
            p.level = 1

        print("-" * 20 + "page5" + "-" * 20)
        slide = self.ppt.slides.add_slide(self.ppt.slide_layouts[1])
        slide.placeholders[0].text = self.title

        body_shape = slide.placeholders[1]
        tf = body_shape.text_frame
        tf.text = self.data4_title

        for data in self.data4:
            p = tf.add_paragraph()
            p.text = data
            p.level = 1

    def show_slide(self):
        for slide in self.ppt.slides:
            print(slide)


if __name__ == "__main__":
    obj = PPT()
